﻿using FluentNHibernate.Mapping;
using Utility.Persistence_Service_Test.Entities;

namespace Utility.Persistence_Service_Test.Mappings
{
    public class BesucherMap : ClassMap<Besucher>
    {
        public BesucherMap()
        {
            Id(x => x.Id)
                .GeneratedBy.Identity()
                .Length(11);
            Map(x => x.Nummer)
                .Not.Nullable()
                .Length(11)
                .Unique();
            Map(x => x.Vorname)
                .Nullable()
                .Length(150);
            Map(x => x.Nachname)
                .Not.Nullable()
                .Length(150);
            References(x => x.Bankkonto)
                .Cascade.All()
                .Not.Nullable()
                .Not.LazyLoad();
            HasMany(x => x.Kinokarten)
                .Cascade.All()
                .Inverse();
        }
    }
}
